<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Simple demo</title>
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript" src="fullAvatarEditor.js"></script>

</head>
<body>
    <div style="width: 630px; margin: 0 auto;">
        <h1 style="text-align: center">头像上传</h1>
        <div>
            <p id="swfContainer">
                本组件需要安装Flash Player后才可使用，请从<a href="http://www.adobe.com/go/getflashplayer">这里</a>下载安装。
            </p>
        </div>
    </div>
    <script type="text/javascript">
        swfobject.addDomLoadEvent(function () {
            var swf = new fullAvatarEditor("swfContainer", {
                id: 'swf',
                upload_url: '../../View/Comon/UploadFiles.ashx?Action=TX&UserName=lyh',
                tab_visible: false
            }, function (msg) {
                switch (msg.code) {
                    case 3:
                        if (msg.type == 0) {
                            alert("摄像头已准备就绪且用户已允许使用。");
                        }
                        else if (msg.type == 1) {
                            alert("摄像头已准备就绪但用户未允许使用！");
                        }
                        else {
                            alert("摄像头被占用！");
                        }
                        break;
                    case 5:
                        if (msg.type == 0) {
                            if (msg.content.sourceUrl) {
                                alert("原图已成功保存至服务器，url为：\n" + msg.content.sourceUrl);
                            }
                            else {
                                alert("头像已成功保存至服务器，url为：\n" + msg.content.avatarUrls.join("\n"));
                            }
                        }
                        break;
                }
            }
            );
            document.getElementById("upload").onclick = function () {
                swf.call("upload");
            };
        });
    </script>
</body>
</html>
